package small.common.limit;

/**
 * 快速失败
 *
 * @author jinzhou
 * @data 2023/4/7 17:36
 */
public class DefaultTrafficShaping implements TrafficShaping {

    /**
     * 流量控制阈值计数
     */
    private long count;

    public DefaultTrafficShaping(long count) {
        this.count = count;
    }

    @Override
    public boolean canPass(TrafficShapingNode node, long acquireCount) {
        double curCount = node.passQps();
        if (curCount + acquireCount > count) {
            return false;
        }
        return true;
    }
}
